home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / LSIZE.ASM < prev    next >
Assembly Source File  |  1991-10-16  |  2KB  |  120 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7. ;
  8. ; LSize- Returns the number of print positions required by an integer value.
  9. ;       On Input:
  10. ;                       DX:AX- Integer to get the size of.
  11. ;
  12. ;       On Output:
  13. ;                       AX: Digit count for the integer.
  14. ;
  15.         public  sl_LSize
  16. sl_LSize        proc    far
  17.         push    dx
  18.         cmp     dx, 0
  19.         jge     LSize2
  20. ;
  21. ; Negate DX:AX
  22. ;
  23.         neg     dx
  24.         neg     ax
  25.         sbb     dx, 0
  26. ;
  27.         call    GetULSize
  28.         inc     ax
  29.         pop     dx
  30.         ret
  31. ;
  32. LSize2:         call    GetULSize
  33.         pop     dx
  34.         ret
  35. sl_LSize        endp
  36. ;
  37. ; ULSize- Same as above, except for unsigned numbers.
  38. ;
  39.         public  sl_ULSize
  40. sl_ULSize       proc    far
  41.         call    GetULSize
  42.         ret
  43. sl_ULSize       endp
  44. ;
  45. ; GetUSize- Does the actual size comparison.
  46. ;
  47. GetULSize       proc    near
  48.         cmp     dx, 0
  49.         jne     GUSA
  50. ;
  51.         cmp     ax, 10
  52.         jae     GUS1
  53.         mov     ax, 1
  54.         ret
  55. ;
  56. GUS1:           cmp     ax, 100
  57.         jae     GUS2
  58.         mov     ax, 2
  59.         ret
  60. ;
  61. GUS2:           cmp     ax, 1000
  62.         jae     GUS3
  63.         mov     ax, 3
  64.         ret
  65. GUS3:           cmp     ax, 10000
  66.         jae     GUS4
  67.         mov     ax, 4
  68.         ret
  69. ;
  70. GUS4:           mov     ax, 5
  71.         ret
  72. ;
  73. GUSA:           push    dx
  74.         cmp     ax, 86a0h               ;Low (100,000)
  75.         sbb     dx, 1                   ;High(100,000)
  76.         pop    dx
  77.         jb      GUS5
  78.         push    dx
  79.         cmp     ax, 0bba0h              ;Low (900,000)
  80.         sbb     dx, 0dh                 ;High(900,000)
  81.         pop    dx
  82.         jb      GUS6
  83.         push    dx
  84.         cmp     ax, 5440h               ;low (9,000,000)
  85.         sbb     dx, 89h                 ;high(9,000,000)
  86.         pop    dx
  87.         jb      GUS7
  88.         push    dx
  89.         cmp     ax, 4a80h               ;low (90,000,000)
  90.         sbb     dx, 55dh                ;high(90,000,000)
  91.         pop    dx
  92.         jb      GUS8
  93.         push    dx
  94.         cmp     ax, 0e900h              ;low (900,000,000)
  95.         sbb     dx, 35a4h               ;high(900,000,000)
  96.         pop    dx
  97.         jb      GUS9
  98.         mov     ax, 10
  99.         ret
  100. ;
  101. GUS5:           mov     ax, 5
  102.         ret
  103. ;
  104. GUS6:           mov     ax, 6
  105.         ret
  106. ;
  107. GUS7:           mov     ax, 7
  108.         ret
  109. ;
  110. GUS8:           mov     ax, 8
  111.         ret
  112. ;
  113. GUS9:           mov     ax, 9
  114.         ret
  115. ;
  116. GetULSize       endp
  117. ;
  118. stdlib        ends
  119.         end
  120.